exports.install = function (Vue, options) {
  /**
   *  弹出框
   * @param title
   * @param content
   * @param type
   * @param onOk
   * @param onCancel
   * @returns {boolean}
   */
  Vue.prototype.msgTip = function ({title, content,type,onOk,onCancel}) {
//type:'danger'
    this.$confirm({
      title: title,
      content: content,
      okText: '确定',
      okType: type,
      cancelText: '取消',
      onOk() {
        onOk();
      },
      onCancel() {
        onCancel();
      },
    });
    return false;
  };

  /**
   * 检查登录状态
   * @param code
   */
  Vue.prototype.checkStatus = function (code) {
    if(code==13){
      let routeUrl = this.$router.resolve({
        path: '/UserLogRegi',
      });
      window.open(routeUrl.href, '_self');
      return;
    }
  }

  /**
   * 获取cookie
   * @param cookie_name
   * @returns {string}
   */
  Vue.prototype.getCookie = function(cookie_name) {
    var allcookies = document.cookie;
    //索引长度，开始索引的位置
    var cookie_pos = allcookies.indexOf(cookie_name);

    // 如果找到了索引，就代表cookie存在,否则不存在
    if (cookie_pos != -1) {
      // 把cookie_pos放在值的开始，只要给值加1即可
      //计算取cookie值得开始索引，加的1为“=”
      cookie_pos = cookie_pos + cookie_name.length + 1;
      //计算取cookie值得结束索引
      var cookie_end = allcookies.indexOf(";", cookie_pos);

      if (cookie_end == -1) {
        cookie_end = allcookies.length;

      }
      //得到想要的cookie的值
      var value = unescape(allcookies.substring(cookie_pos, cookie_end));
    }
    return value;
  }
};
